# Replication of Figure 2
# Krawatzek / Soroka
# Defending History? The Impact of Context and Speaker in Russia
# Perspectives on Politics
# DOI

require(ggplot2)
require(stringr)
setwd("Insert your local directory")
load("Figure2Data.RData")

Figure2Data$Response <- as.factor(as.character(Figure2Data$Response))
levels(Figure2Data$Response)
Figure2Data$Response <- factor(Figure2Data$Response, levels(Figure2Data$Response)[c(3,4,2,1)])

ggplot(Figure2Data, aes(x=Response, y=n, fill=Response)) + 
  geom_bar(stat="identity", position = "dodge") +
  labs(title=str_wrap("Do you agree that the state should regulate with laws how people are allowed to talk about our country's past in public"), 
       x="Data from ZOiS survey of 2,110 Russians aged 18-65", y="Number of Respondents") + 
  geom_text(data=Figure2Data, aes(label=ratio),
            position=position_dodge(0.9), vjust = -.5) +
  #scale_fill_brewer(palette="Dark2") +
  scale_fill_grey() +
  theme(plot.title=element_text(hjust=0.5, size=20),
        axis.title.y=element_text(vjust=1,size=16),
        axis.text.y=element_text(size=16),
        legend.text=element_text(size=16),
        legend.key.size=unit(3, 'lines'),
        legend.title=element_blank(),
        axis.text.x=element_blank())
ggsave("Figure2-colour.pdf", width = 12, height = 8)
ggsave("Figure2-bw.pdf", width = 12, height = 8)